﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Lote.aspx.cs" Inherits=" RzCorportativo.Views.Cadastros.Lote" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="LeftContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<script src="<%=this.ResolveUrl("~/Recursos/j/eComplete.js")%>" type="text/javascript"></script>
    <h1>
        Lote
    </h1>
    <hr />
    <asp:HiddenField runat="server" ID="FornecedorId" />
    <asp:HiddenField runat="server" ID="LoteId" />
    <div class="controls controls-row">
        <asp:TextBox runat="server" ID="CNPJ" mask="cnpj" placeholder="CNPJ do fornecedor" data-toggle="tooltip" title="Cnpj Fornecedor" data-placement="left" 
         name="complete"
         value="" 
         auto-complete="true" 
         eid="descricao" 
         requesttype="post" 
         contenttype="application/json; charset=utf-8"
         isasync="true"
         length="1"
         datatype="json" 
         templeted="true" 
         onrender="getItem" 
         onerror="getError" 
         onselected="selectedItem" />
        <asp:TextBox runat="server" ID="Numero" placeholder="Númerod do lote" data-toggle="tooltip" title="Número do lote" data-placement="left"/>
    </div>
    <div class="controls controls-row">
        <asp:TextBox runat="server" ID="DataEntrega" date="true" mask="calendar" max-year='5'
            min-date='now' placeholder="Data de entrega" data-toggle="tooltip" title="Data de entrega" data-placement="left"/>
        <asp:TextBox runat="server" ID="DataValidade" date="true" mask="calendar" max-year='5'
            min-date='now' placeholder="Data de validade" data-toggle="tooltip" title="Data de validade" data-placement="left"/>
    </div>
    <div data-spy="scroll" data-target="" data-offset="0" class="scrollspy-example">
        <asp:TextBox runat="server" ID="Valor" placeholder="Valor R$" data-toggle="tooltip" title="Valor R$" data-placement="left" mask="money" />
        <asp:TextBox runat="server" ID="Quantidade" placeholder="Quantidade de itens" data-toggle="tooltip" title="Quantidade de itens" data-placement="left" mask="number" range="7" />
    </div>
    <div data-spy="scroll" data-target="" data-offset="0" class="scrollspy-example">
        <asp:Button Text="salvar" runat="server" ID="salvar" CssClass="btn btn-success" 
            onclick="salvar_Click" />
        <asp:Button Text="voltar" runat="server" ID="voltar" CssClass="btn btn-info"  />
    </div>

    <script type="text/javascript">
        function getItem(ul, item) {

            var inner_html = '<a><div class="list_item_container"><div class=""><strong>Nome:</strong> ' +
                            item.Nome + '</div><div class="description"><strong>CNPJ: </strong>' +
                            item.Cnpj + '</div></div></a>';
            return $("<li style='width:350px'></li>")
            .data("item.autocomplete", item)
            .append(inner_html)
            .appendTo(ul);
        }
        function getError(e) {
            var _alert = new Alert();
            _alert.Name = "erroGeral";
            _alert.Type = AlertType.Error;
            _alert.AddMessage(e.d ? e.d : e.responseText);
            _alert.Show();
        }

        function sourceError(e) {
            var _alert = new Alert();
            _alert.Name = "erroGeral";
            _alert.Type = AlertType.Error;
            _alert.AddMessage(e.d ? e.d : e.responseText);
            _alert.Show();

        }
        function selectedItem(event, ui, context) {
            var item = ui.item && ui.item.value ? ui.item : context;
            if (item.FornecedorId) {
                $("input[id$='FornecedorId']").val(item.FornecedorId.toString(10))
            }
        }
    </script>
</asp:Content>
